#!/bin/bash

pwdDir=`pwd`
# echo "${pwdDir}"

# ---------------------------------------------------------

# 加载环境变量
variableGroup="${pwdDir}/variable-group/"
sourceVariableFile="${variableGroup}variableFile.sh"
# 输出文件路径
# echo ${sourceVariableFile}
# 加载/执行文件里的内容
source ${sourceVariableFile}


# 加载代码检出,更新
# svnUpdate="${pwdDir}/svnUpdate/"
# svnUpdateFile="${svnUpdate}svnUpdate.sh"
# echo ${svnUpdateFile}
source ${svnUpdateFile}

# 加载需要处理的文件内容
# fileContentDir="${pwdDir}/operationFile/"
# fileContentFile="${fileContentDir}fileContent.txt"
# echo ${fileContentFile}
# source ${fileContentFile}

# echo ${ymd}
# echo ${ymdhms}
# -----------------------逻辑处理-开始----------------------

if [ ! -e "${logDir}" ]; then
	mkdir -p ${logDir}
fi
# 清空日志
echo "" > ${logFile}
# 把php-bak 目录下的指定目录/文件 复制到php的目录/文件下
# 循环文件里内容
for fileName in ` cat ${fileContentFile} ` ; do
	# echo ${fileName}
	mvFile="${phpDir}${fileName}"
	mvNewFile="${phpDir}${fileName}${bakExtend}"

	copyFileTomvFile="${phpBakDir}${fileName}"
	# mvNewFile="${phpBakDir}${fileName}${bakExtend}"
	echo " 目标 ${mvFile} "  >> ${logFile}
	if [ -e "${mvFile}" ]; then
		# 目标存在 进行备份 再复制
		echo " 目标存在 mv  ${mvFile}   ${mvNewFile}"  >> ${logFile}
		echo " 进行备份 再复制 "  >> ${logFile}
		mv  ${mvFile} ${mvNewFile}   >> ${logFile}
	else
		# 目标不存在
		echo " 目标不存在 直接复制"   >> ${logFile}
	fi
	
	echo " cp -r ${copyFileTomvFile}  ${mvFile} "   >> ${logFile}
	cp -r ${copyFileTomvFile}  ${mvFile}   >> ${logFile}
	
	# ls -la ${mvFile}
	echo " diff ${mvFile} ${mvNewFile} "  >> ${logFile}
	diff ${mvFile} ${mvNewFile}  >> ${logFile}

done


:<<memoAl 
pwdPath="."

sourceFile="${pwdPath}/fileContent.txt"
echo ${sourceFile}
source ${sourceFile}

memoAl



